#ifdef _WIN32
	#include "boinc_win.h"
#else
	#include "config.h"
#endif

#ifndef _WIN32
	#include <cstdio>
	#include <cctype>
	#include <ctime>
	#include <cstring>
	#include <cstdlib>
	#include <csignal>
	#include <unistd.h>
#endif

#define BOINC_APP_GRAPHICS
#ifdef BOINC_APP_GRAPHICS
	#include "graphics_api.h"
	#include "graphics_lib.h"
#endif

#include <stdio.h>
#include <iostream>
#include <fstream>

#include "diagnostics.h"
#include "util.h"
#include "boinc_api.h" 
#include "windows.h"
#include "guicon.h"

#include "ddas_globals.h"
#include "ddas_client_setup.h"
#include "ddas_client_io.h"
#include "ddas_debug.h"
#include "ddas_results.h"
#include "ddas_main.h"

using namespace std;

int main(int argc, char **argv)
{
	//initialize boinc's diagnostics
	boinc_init_diagnostics
	(
        BOINC_DIAG_DUMPCALLSTACKENABLED		|
        BOINC_DIAG_HEAPCHECKENABLED			|
        BOINC_DIAG_MEMORYLEAKCHECKENABLED	|
        BOINC_DIAG_TRACETOSTDERR			|
        BOINC_DIAG_REDIRECTSTDERR			| 
		BOINC_DIAG_REDIRECTSTDOUT			  
    );

	//start new graphics thread and pass it a reference to worker function (defined in ddas_main.h)
	int result = boinc_init_graphics(worker);

	//record error if one exists
	if( result ) boinc_finish( result );
}

#ifdef _WIN32
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR Args, int WinMode) 
{
    LPSTR command_line;
    char* argv[100];
    int argc;

    command_line = GetCommandLine();
    argc = parse_command_line( command_line, argv );
    return main(argc, argv);
}
#endif